﻿using Dragon.Library.Utility.NHibernate;

namespace Dragon.Library.Framework.Dao
{
    public partial class BaseDao<T, TKeyT>
    {
        public void Dispose()
        {
            try
            {
                if (SessionKey != null)
                    SessionFactory.CloseSession(SessionKey);
            }
            catch (System.Exception ex) { throw ex; }
        }

        public void ConnectionOpen()
        {
            Session.Connection.Open();
        }

        public void ConnectionClose()
        {
            Session.Connection.Close();
        }

        public void Clear()
        {
            Session.Clear();
            SessionFactory.CloseSession(SessionKey);
            SessionKey = string.Empty;
            _session = null;
        }
    }
}
